import 'package:dance_todo/db/bean_event.dart';
import 'package:dance_todo/db/bean_record.dart';
import 'package:dance_todo/db/object_box.dart';
import 'package:dance_todo/pages/controller_home.dart';
import 'package:dance_todo/pages/controller_schedule.dart';
import 'package:dance_todo/pages/controller_statistic.dart';
import 'package:dance_todo/pages/controller_trophy.dart';
import 'package:dance_todo/pages/page_splash.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'package:lottie/lottie.dart';

import 'pages/page_home.dart';

late ObjectBox objectbox;
late final LottieComposition lottieLike;
late final LottieComposition lottieTrophy;
late final LottieComposition lottieCalender;
late final LottieComposition lottieCreate;
late final LottieComposition lottieSchedule;

late final eventBox;
late final recordBox;

void main() async {
  await GetStorage.init();
  // //顶部状态栏透明
  // SystemChrome.setSystemUIOverlayStyle(
  //     SystemUiOverlayStyle(statusBarColor: Colors.transparent));
  WidgetsFlutterBinding.ensureInitialized();
  objectbox = await ObjectBox.create();
  eventBox = objectbox.store.box<Event>();
  recordBox = objectbox.store.box<Record>();
  runApp(
    GetMaterialApp(
      home: App(),
      routingCallback: (routing) {},
      onInit: () {
        Get.put(HomeCtrl());
        Get.put(ScheduleCtrl());
        Get.put(TrophyCtrl());
        Get.put(StatisticCtrl());


      },
      theme: ThemeData(fontFamily: "MiSansBold"),
      builder: (context, widget) {
        return MediaQuery(
          //设置文字大小不随系统设置改变
          data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
          child: widget!,
        );
      },
      // theme: ThemeData.dark().copyWith(
      //   shadowColor: Colors.black87,
      //   bottomAppBarColor: Colors.blueGrey[900],
      //   backgroundColor: Colors.grey[300],
      // ),
    ),
  );
}

class App extends StatefulWidget {
  @override
  State<App> createState() => _AppState();
}

class _AppState extends State<App> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return const SplashPage();
  }
}
